Next: Android shell setup, Previous: Remote programs, Up: Configuration [Contents][Index]
TRAMP checks for the availability of standard
programs in the usual locations. Common tactics include
successively trying test -e, /usr/bin/test
-e, and /bin/test -e. ls -d is
another approach. But these approaches do not help with these new
login patterns.
When TRAMP encounters two-factor logins or additional challenge questions, such as entering birth date or security code or passphrase, TRAMP needs a few more configuration steps to accommodate them.
The difference between a password prompt and a passphrase prompt is that the password for completing the login while the passphrase is for authorizing access to local authentication information, such as the ssh key.
There is no one configuration to accommodate all the variations in login security, especially not the exotic ones. However, TRAMP provides a few tweaks to address the most common ones.
tramp-shell-prompt-pattern is for remote
login shell prompt, which may not be the same as the local
login shell prompt, shell-prompt-pattern. Since
most hosts use identical prompts, TRAMP sets a
similar default value for both prompts.
TRAMP uses tramp-password-prompt-regexp to distinguish between prompts for passwords and prompts for passphrases. By default, tramp-password-prompt-regexp handles the detection in English language environments. See a localization example below:
(setq
tramp-password-prompt-regexp
(concat
"^.*"
(regexp-opt
'("passphrase" "Passphrase"
;; English
"password" "Password"
;; Deutsch
"passwort" "Passwort"
;; Français
"mot de passe" "Mot de passe") t)
".*:\0? *"))
Similar localization may be necessary for handling wrong password prompts, for which TRAMP uses tramp-wrong-passwd-regexp.
tset and other questionsTo suppress inappropriate prompts for terminal type,
TRAMP sets the TERM to
dumb before the remote login process begins via
the variable tramp-terminal-type. This will
silence common tset related prompts.
TRAMP’s strategy for handling such prompts (commonly triggered from login scripts on remote hosts) is to set the environment variables so that no prompts interrupt the shell initialization process.
An alternative approach is to configure
TRAMP with strings that can identify such
questions using tramp-actions-before-shell.
Example:
(defconst my-tramp-prompt-regexp
(concat (regexp-opt '("Enter the birth date of your mother:") t)
"\\s-*")
"Regular expression matching my login prompt question.")
(defun my-tramp-action (proc vec)
"Enter \"19000101\" in order to give a correct answer."
(save-window-excursion
(with-current-buffer (tramp-get-connection-buffer vec)
(tramp-message vec 6 "\n%s" (buffer-string))
(tramp-send-string vec "19000101"))))
(add-to-list 'tramp-actions-before-shell
'(my-tramp-prompt-regexp my-tramp-action))
When a user name is the same as a variable name in a local
file, such as .profile, then
TRAMP may send incorrect values for
environment variables. To avoid incorrect values, change the
local variable name to something different from the user
name. For example, if the user name is FRUMPLE,
then change the variable name to
FRUMPLE_DIR.
When the remote host’s .profile is also used for shells other than Bourne shell, then some incompatible syntaxes for commands in .profile may trigger errors in Bourne shell on the host and may not complete client’s TRAMP connections.
One example of a Bourne shell incompatible syntax in
.profile: using export FOO=bar
instead of FOO=bar; export FOO. After remote
login, TRAMP will trigger an error during its
execution of /bin/sh on the remote host because
Bourne shell does not recognize the export command as entered
in .profile.
Likewise, (~) character in paths will cause
errors because Bourne shell does not do (~)
character expansions.
One approach to avoiding these incompatibilities is to make all commands in ~/.shrc and ~/.profile Bourne shell compatible so TRAMP can complete connections to that remote. To accommodate using non-Bourne shells on that remote, use other shell-specific config files. For example, bash can use ~/.bash_profile and ignore .profile.
TRAMP redefines the remote shell prompt internally for robust parsing. This redefinition affects the looks of a prompt in an interactive remote shell through commands, such as M-x shell. Such prompts, however, can be reset to something more readable and recognizable using these TRAMP variables.
TRAMP sets the INSIDE_EMACS
variable in the startup script file
~/.emacs_SHELLNAME.
SHELLNAME is bash or equivalent
shell names. Change it by setting the environment variable
ESHELL in the .emacs as
follows:
(setenv "ESHELL" "bash")
Then re-set the prompt string in ~/.emacs_SHELLNAME as follows:
# Reset the prompt for remote Tramp shells.
if [ "${INSIDE_EMACS/*tramp*/tramp}" == "tramp" ] ; then
PS1="[\u@\h \w]$ "
fi
busybox / ncTRAMP’s nc method uses
the nc command to install and execute a listener
as follows (see tramp-methods):
# nc -l -p 42
The above command-line syntax has changed with
busybox versions. If nc refuses the
-p parameter, then overwrite as follows:
(add-to-list
'tramp-connection-properties
`(,(regexp-quote "192.168.0.1") "remote-copy-args" (("-l") ("%r"))))
where ‘192.168.0.1’ is the remote host IP address (see Predefined connection information).
Next: Android shell setup, Previous: Remote programs, Up: Configuration [Contents][Index]